package aupdg.data.model.impl;

import aupdg.logic.analysis.SecurityLevel;
import aupdg.data.model.Node;

/**
 * Implements the interface Node. It's an abstract class that implements the
 * common methods of all kind of nodes.
 *
 * @author AA and CJ
 */
public abstract class AuGenericNode implements Node {

    /**
     * ID of the node in the LDG. ID is set when added to an LDG (consecutive
     * number).
     */
    public int id;
    /**
     * Label of node (for the presentation tier).
     */
    protected String label;
    private boolean processed;
    /**
     * Security level. Low = 0 High = 1
     */
    private SecurityLevel level;

    /**
     * Constructor. It assigns the label provided in the argument. Sets the
     * boolean "processed" as false by default.
     *
     * @param label
     */
    public AuGenericNode(String label) {
        this.label = label;
        this.processed = false;
        this.level = SecurityLevel.LOW;
    }

    @Override
    public void setLabel(String label) {
        this.label = label;
    }

    @Override
    public String getLabel() {
        return this.label;
    }

    @Override
    public boolean isProcessed() {
        return processed;
    }

    @Override
    public void setProcessed(boolean processed) {
        this.processed = processed;
    }

    @Override
    public void setNodeIdInGraph(int id) {
        this.id = id;
    }

    @Override
    public void setSecurityLevel(SecurityLevel level) {
        this.level = level;
    }

    @Override
    public SecurityLevel getLevel() {
        return this.level;
    }

    @Override
    public int getId() {
        return this.id;
    }

    @Override
    public String toString() {
        return label + getId();
    }

    /*
     * public boolean equals(Object obj) { if (obj instanceof AuGenericNode) {
     * AuGenericNode node = (AuGenericNode) obj; if (this.label == node.label &&
     * this.innerID == node.innerID) return true; } return false; }
     */
}
